package manager

import (
	"quant/backend/entity"
)

type ConfigManager struct {
	// 引入公共类
	// baseService
	*BaseManager[entity.ConfigEntity]
}

func NewConfigManager() *ConfigManager {
	return &ConfigManager{
		BaseManager: newManager[entity.ConfigEntity](),
	}
}

func (cm *ConfigManager) GetMap() (map[string]string, error) {
	configList, err := cm.FindAll()
	if err != nil {
		return nil, err
	}
	var configMap = make(map[string]string)
	for _, config := range configList {
		configMap[config.Name] = config.Content
	}
	return configMap, nil
}
